package com.yi.wood.dao;

import com.yi.wood.entity.Territory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

/**
 * @author moyi
 * @since 1.0
 */
public interface TerritoryDao extends JpaRepository<Territory, Long> {
    /**
     * 保存用户领地信息
     *
     * @param name       领地名字
     * @param lat        领地经度坐标
     * @param lon        领地维度坐标
     * @param createTime 占领时间
     * @param userId     用户ID
     * @return 是否成功
     */
    @Query(value = "insert into territory(name,create_time,user_id) values(?1,?2,?3,?4,GeomFromText('POINT(?5,?6)'))", nativeQuery = true)
    int addTerritory(String name, Date createTime, Long userId, Double lat, Double lon);
}
